package com.jzr.medical.db1.service.Impl;

import com.jzr.medical.common.LayServiceImpl;
import com.jzr.medical.db1.dto.ShiftPlanDto;
import com.jzr.medical.db1.mapper.TShiftPlanMapper;
import com.jzr.medical.db1.model.TShiftPlan;
import com.jzr.medical.db1.service.ShiftPlanService;
import com.jzr.medical.db1.vo.ShiftPlanVo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShiftPlanServiceImpl extends LayServiceImpl<TShiftPlanMapper,TShiftPlan,ShiftPlanVo,Integer> implements ShiftPlanService {
    @Override
    public List<ShiftPlanVo> list(ShiftPlanDto dto) {
        return baseMapper.list(dto);
    }

    @Override
    public ShiftPlanDto getById(Integer id, Integer staffType) {
        return baseMapper.getById(id,staffType);
    }

    @Override
    public ShiftPlanVo saveAndGet(ShiftPlanVo record) {
        if(record.getId()!=null){
            return updateAndGet(record);
        }
        setDefaultValue(record);
        save(record);
        return record;
    }

    @Override
    public ShiftPlanVo updateAndGet(ShiftPlanVo record) {
        if(record.getId()==null){
            return saveAndGet(record);
        }
        setDefaultValue(record);
        updateById(record);
        return record;
    }
}
